package billrestauration.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.context.annotation.Lazy;

@Entity
@Lazy(value=false)
@Table
public class Prix {
	public static final int DEVISE_EURO=0x00;//"EUR";
	public static final int DEVISE_DOLLAR_US=0x01;//"USD";
	public static final int DEVISE_DOLLAR_CA=0x02;//"CAD";
	public static final int DEVISE_LIVRE_STERLING=0x03;//"GBP";
	public static final int DEVISE_CFA=0x04;//"CFA";
	
	public static final String DEVISE_EURO_SYMBOLE="&euro;";
	public static final String DEVISE_DOLLAR_US_SYMBOLE="$";
	public static final String DEVISE_DOLLAR_CA_SYMBOLE=" $ CAN";
	public static final String DEVISE_LIVRE_STERLING_SYMBOLE="£";
	public static final String DEVISE_CFA_SYMBOLE="CFA";
	
	public Prix(double prix) {
		super();
		this.devise=Prix.DEVISE_EURO;
		this.prix = prix;
	}
	public Prix(int devise, double prix) {
		super();
		this.devise = devise;
		this.prix = prix;
	}
	public Prix() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Prix(long id, int devise, double prix) {
		super();
		this.id = id;
		this.devise = devise;
		this.prix = prix;
	}
	@Id
	@Column
	@GeneratedValue
private long id;
	@Column(nullable=false)
	
private int devise;
	@Column(nullable=false)
	private double prix;
	protected String getDeviseSymbole(){
		switch (this.devise) {
		case DEVISE_CFA:
			 return DEVISE_CFA_SYMBOLE;
		case DEVISE_DOLLAR_CA:return DEVISE_DOLLAR_CA_SYMBOLE;
		case DEVISE_DOLLAR_US :return DEVISE_DOLLAR_US_SYMBOLE;
		case DEVISE_EURO:return DEVISE_EURO_SYMBOLE;
		default:
			return Prix.DEVISE_EURO_SYMBOLE;
		}
	}
	@Override
	public String toString() {
		return " " + prix + " "+getDeviseSymbole()+"";
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public int getDevise() {
		return devise;
	}
	public void setDevise(int devise) {
		this.devise = devise;
	}
	public double getPrix() {
		return prix;
	}
	public void setPrix(double prix) {
		this.prix = prix;
	}
}
